import Config.GlobalVariables;
import Controller.SupervisorController;
import DAO.ProductsDAO;
import Entity.ChargingStations;
import Entity.Robot;
import Entity.RobotStatus;
import Service.SupervisorService;
import View.Warehouse;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

import static Config.GlobalVariables.*;

public class Main {

    public static void main(String[] args) {
        // 1. 初始化数据库DAO
        GlobalVariables.init();
        // 2. 初始化机器人列表(假设你有3个机器人)
        List<Robot> robotList = new ArrayList<>();
        ChargingStations Astation=chargingStation1;
        ChargingStations Bstation=chargingStation2;
        ChargingStations Cstation=chargingStation3;
        // Robot(String id, int x, int y, RobotStatus status, ...)
        robotList.add(new Robot("R1",0,0,RobotStatus.INACTIVE,300,0.5,100,"src\\View\\images\\a-orange.png",Astation));
        robotList.add(new Robot("R2",5,4,RobotStatus.INACTIVE,300,0.5,100,"src\\View\\images\\b-green.png",Bstation));
        robotList.add(new Robot("R3",10,10,RobotStatus.INACTIVE,300,0.5,100,"src\\View\\images\\c-red.png",Cstation));
        // 3. 创建SupervisorService
        SupervisorService supervisorService = new SupervisorService(robotList);

        // 4. 创建SupervisorController（GUI）
        SupervisorController supervisorController = new SupervisorController(supervisorService);
        supervisorController.setVisible(true);
        SwingUtilities.invokeLater(() -> {
            Warehouse frame1 = new Warehouse(supervisorService.getAllRobots());
            frame1.setVisible(true);
        });


        // 现在即可同时操作两个界面:
        // - SupervisorController: 查看/控制机器人状态
        // - OrderController: 随机产生订单

        // SupervisorService 的后台线程会从队列中取订单，寻找空闲机器人执行搬运




    }
}
